#!/bin/bash

# log_file=/dev/stdout
# log_file=/dev/stderr
mkdir -p ~/.local/bad/log/
log_file=~/.local/bad/log/badmsg.log

# logmsg [-t D|DEBUG|I|INFO] <MSG>
# logmsg -t I "wifi downed!" -> "[2021-12-21 20:39:59:001] I wifi downed!"

time=`date "+[%F %T]"`

type="I"
msg=${1}
key=${1}
if [[ '-t' == $key ]] ; then
	type=${2}	
	msg=${3}
fi

echo $time $type $msg  >> $log_file
